import re
from typing import Dict


class Hero(Dict):
    def __init__(self, info_str) -> None:
        self.info = info_str
        self["角色名"] = self.__match(r"(?<=\|)角色名=(.*?)(?=\n)")
        self["角色职业"] = self.__match(r"(?<=\|)角色职业=(.*?)(?=\n)")
        self["天赋名称"] = self.__match(r"(?<=\|)天赋名称=(.*?)(?=\n)")
        self["初始绝学"] = self.__match(r"(?<=\|)初始绝学=(.*?)(?=\n)")
        五内上 = self.__match(r"(?<=\|)五内上=(.*?)(?=\n)").split(",")
        self["五内上"] = 五内上[1:]
        self["五内上中"] = self.__match(r"(?<=\|)五内上中=(.*?)(?=\n)")
        五内中 = self.__match(r"(?<=\|)五内中=(.*?)(?=\n)").split(",")
        self["五内中"] = 五内中[1:]
        self["五内中下"] = self.__match(r"(?<=\|)五内中下=(.*?)(?=\n)")
        五内下 = self.__match(r"(?<=\|)五内下=(.*?)(?=\n)").split(",")
        self["五内下"] = 五内下[1:]
        self["五内战阵"] = self.__match(r"(?<=\|)五内战阵=(.*?)(?=\n)")

    def __match(self, format):
        value = re.search(format, self.info, re.MULTILINE)
        return value.group(1) if value else ""
